package com.dongdong.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

/**
 * @Deacription TODO
 * @Author Lenovo
 * @Date 2020/12/17 14:53
 * @Version 1.0
 **/
@Configuration
public class MyFreeMarketConfig {

    @Value("${freemarker.templateLoaderPath}")
    private String templateLoaderPath;

    @Value("${freemarker.defaultEncoding}")
    private String defaultEncoding;

    @Bean
    public FreeMarkerConfigurer freeMarkerConfigurer(){
        //创建容器
        FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
        //创建freemarker模板所在路径
        configurer.setTemplateLoaderPath(templateLoaderPath);
        //设置编码
        configurer.setDefaultEncoding(defaultEncoding);
        return configurer;
    }
}

